# -*- coding: utf-8 -*-
# @File:     save_minio_tool.py
# @Author:
# @DateTime: 2025/06/19/11:11

from .minioClient import go_upload_file, go_upload_file_have_size
import base64
from ..tool import get_time_string

image_list = ['png', 'jpg', 'jpeg']
svg_list = ["svg"]


def save_file_to_stroage(file, forlder="", file_name=None, file_type="png"):
    if file_name is None:
        file_name = get_time_string()

    file_path = f"{forlder}/{file_name}.{file_type}"

    if str(file_type).lower() in image_list:
        content_type = "image/png"
    elif str(file_type).lower() in svg_list:
        content_type = "image/svg+xml"
    else:
        content_type = "application/octet-stream"

    ret = go_upload_file(file, path_name=file_path, content_type=content_type)
    assert ret == 1, '文件上传失败'
    return file_path



